<?php

include'../classes/db.php';

$x=new DbConnect();
$con=$x->getConnection();

$emp=addslashes($_GET['regno']);
$size=strlen($emp);

//check number that input is registration number or empoyee number 
if($size=="4")//if it is emp_no
{
	$result=mysql_query("select f_name,l_name from employee where emp_no='$emp'",$con);
	$num=mysql_num_rows($result);
	if($num==0)
		{
			echo"false";
		} 
		else
		{
		while($row=mysql_fetch_array($result))
			{
			$fname=$row['f_name'];
			$lname=$row['l_name'];
			}    
		echo"NAME- "."$fname "." $lname";
		}
}
elseif($size=="5")//if it is reg_no
{ 
	$time_now=mktime(date('H')+5,date('i')+30,date('s'),date('m'),date('d'),date('Y'));
	$year=date('Y',$time_now);//get current year
	$result=mysql_query("select f_name,l_name from student where reg_no='$emp' and year(j_date)='$year'",$con);
	$num=mysql_num_rows($result);
	if($num==0)
		{
		echo"false";
		}
	else
		{
		while($row=mysql_fetch_array($result))
			{
			$fname=$row['f_name'];
			$lname=$row['l_name'];
			}    
		echo"NAME- "."$fname "." $lname";
		}
}
?>
